import java.net.*;
import java.io.*;

public class Sender {

	private String recipient;
	private int port;

	public Sender(String recipient, int port) {
		this.recipient = recipient;
		this.port = port;
	}
	
	public boolean send(String msg) {
		Socket socket;
		try {
			socket = new Socket(recipient, port);
			PrintWriter Ausgabe = new PrintWriter(socket.getOutputStream(),	true);
			Ausgabe.println(msg);
			return true;
		} catch (UnknownHostException e) {
			System.out.println("unknown host: " + e);
			return false;
		} catch (IOException e) {
			System.out.println("ioexception: " + e + " to " + recipient);
			return false;
		}
	}

	public void setRecipient(String recipient) {
		this.recipient = recipient;
	}

	public void setLocalSendingPort(int port) {
		this.port = port;
	}
}